package com.onlyphoto.onlymall.mvp.model

import com.onlyphoto.onlymall.api.Urls
import com.onlyphoto.onlymall.base.BaseEntity
import com.onlyphoto.onlymall.base.BaseModel
import com.onlyphoto.onlymall.base.BaseObserver
import com.onlyphoto.onlymall.bean.response.CouponBean
import com.onlyphoto.onlymall.utils.ConfigUtil
import com.onlyphoto.onlymall.utils.RxTransformer


class MCouponImpl : BaseModel() {

    var url = ""
    fun getStoreCoupons(baseObserver: BaseObserver<ArrayList<CouponBean>>, get_type: Int){
        url = ConfigUtil.instance.getUrl(Urls.COUPON)
        apiService().getStoreCoupons(url, get_type)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }

    fun getUserCoupons(baseObserver: BaseObserver<ArrayList<CouponBean>>, get_type: Int, status: Int){
        url = ConfigUtil.instance.getUrl(Urls.COUPON)
        apiService().getUserCoupons(url, get_type, status)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }

    fun receiveCoupon(baseObserver: BaseObserver<BaseEntity>, couponId: Int, end_tm: Long){
        url = ConfigUtil.instance.getUrl(Urls.COUPON)
        apiService().receiveCoupon(url, couponId, end_tm)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }
}
